package com.example.home.adapter.provider

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.home.R
import com.example.home.adapter.NominateItemType
import com.example.home.databinding.ItemHomeTitleBinding
import com.example.entity.BaseEntity
import com.example.home.entity.viewdata.TitleCardViewData

/**
 * 标题UI提供
 * */
class TitleProvider constructor(private val type : Int,private val layoutResId : Int): BaseItemProvider<BaseEntity>() {

    override val itemViewType: Int =type

    override val layoutId: Int = layoutResId

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeTitleBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: BaseEntity) {

        var dataBinding = helper.getBinding<ItemHomeTitleBinding>()

        if (item != null && dataBinding != null ){
            dataBinding.viewData = item as TitleCardViewData
            dataBinding.executePendingBindings()
        }
    }

}